<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group(['namespace'=>'Api'], function (){
    Route::any('/apns/device_token', 'ApnsController@device_token');
    Route::any('/apns/jpush', 'ApnsController@jpush');
    //district
    Route::get('/district/get', 'DistrictController@get');
    Route::get('/district/batchget', 'DistrictController@batchget');
    //block
    Route::any('/block/batchget_item', 'BlockController@batchgetItem');
    Route::any('/tuijian', 'IndexController@tuijian');
    Route::any('/youxuan', 'IndexController@youxuan');

    Route::get('/token', 'TokenController@index');
    Route::get('/token/check', 'TokenController@check');

    Route::any('/account/signin', 'AccountController@signin');
    Route::any('/account/signup', 'AccountController@signup');

    //item
    Route::any('/item/get_item', 'ItemController@getItem');
    Route::any('/item/batchget_item', 'ItemController@batchgetItem');
    Route::any('/item/get_catlog', 'ItemController@getCatlog');
    Route::any('/item/batchget_catlog', 'ItemController@getCatlogList');
    Route::any('/item/get_catlog_tree', 'ItemController@getCatlogTree');

    //shop
    Route::any('/shop/get_shop', 'ShopController@getShop');
    Route::any('/shop/batchget_shop', 'ShopController@batchgetShop');

    //cart
    Route::any('/cart/batchget_item', 'CartController@batchgetItem');
    Route::any('/cart/add', 'CartController@add');
    Route::any('/cart/update_quantity', 'CartController@updateQuantity');
    Route::any('/cart/settlement', 'CartController@settlement');

    //address
    Route::any('/address/get_address', 'AddressController@get_address');
    Route::any('/address/batchget_address', 'AddressController@batchget_address');
    Route::any('/address/set_default', 'AddressController@set_default');
    Route::any('/address/del_address', 'AddressController@del_address');
    Route::any('/address/save', 'AddressController@save');

    //post
    Route::any('/post/batchget_item', 'PostController@batchget_item');
    Route::any('/post/batchget_catlog', 'PostController@batchget_catlog');

    //order
    Route::any('/order/create_order', 'OrderController@createOrder');
    Route::any('/order/get_order', 'OrderController@getOrder');
    Route::any('/order/batchget_order', 'OrderController@batchgetOrder');
    Route::any('/order/close_order', 'OrderController@closeOrder');
    Route::any('/order/confirm_order', 'OrderController@confirmOrder');
    //pay
    Route::any('/alipay/sign', 'AlipayController@sign');
    Route::any('/alipay/query', 'AlipayController@query');
    //express
    Route::any('/express/batchget', 'ExpressController@batchget');
    //pages
    Route::any('/pages/get', 'PagesController@get');
    //feedback
    Route::any('/feedback/save', 'FeedbackController@save');

    //material
    Route::any('/material/upload_img', 'MaterialController@upload_img');

    //user
    Route::any('/user/info', 'UserController@info');
    Route::any('/user/update_info', 'UserController@update_info');
    Route::any('/user/avatar', 'UserController@avatar');
    //security
    Route::any('/security/editpass', 'SecurityController@editpass');
    Route::any('/security/bindmobile', 'SecurityController@bindmobile');
    Route::any('/security/bindemail', 'SecurityController@bindemail');

    //Collection
    Route::any('/collection/add', 'CollectionController@add');
    Route::any('/collection/batchget', 'CollectionController@batchget');

    //version
    Route::any('/version', function (){
        $userAgent = 'time:'.time().','.$_SERVER['HTTP_USER_AGENT'];
        if(strpos($userAgent, 'Android') || strpos($userAgent, 'okhttp')){
            return ajaxReturn(['version'=>3.8, 'userAgent'=>$userAgent]);
        } else {
            return ajaxReturn(['version'=>3.8, 'userAgent'=>$userAgent]);
        }
    });
    //检测登录状态
    Route::get('/checklogin', 'IndexController@checklogin');

    Route::any('/food', 'IndexController@food');
    Route::any('/nutritious', 'IndexController@nutritious');
    Route::any('/fupin', 'IndexController@fupin');

    Route::any('test', 'IndexController@test')->middleware('auth:api');
});
